package com.work.libtest2.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.work.libtest2.dto.AttendenceDTO;
import com.work.libtest2.entity.R;
import com.work.libtest2.service.AttendencecService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ClassName: AttendenceController
 * Package: com.work.libtest2.controller
 * Description:
 *
 * @Author
 * @Create 2024/6/19 21:13
 * @Version 1.0
 */
@RestController
@RequestMapping("/attendence")
public class AttendenceController {

    @Resource
    private AttendencecService attendencecService;

    @GetMapping("/{currentPage}/{pageSize}")
    public R getPage(@PathVariable Integer currentPage, @PathVariable Integer pageSize, AttendenceDTO attendenceDTO){
        IPage<AttendenceDTO> page = attendencecService.getPage(currentPage,pageSize,attendenceDTO);
        if (currentPage > page.getPages()){
            page = attendencecService.getPage((int) page.getPages(),pageSize,attendenceDTO);
        }
        return new R(true,page);
    }

}
